'use strict';
/**
 * @ngdoc directive
 * @name jgappApp.directive:relativeModule
 * @description
 * # relativeModule
 */
angular.module('jgappApp')
    .directive('relativeModule', ["$location", "RelativeModule", "Modulemap", "Util", function($location, RelativeModule, Modulemap, Util) {
        return {
            restrict: 'AE',
            replace: true,
            link: function postLink(scope, element, attrs) {
                var param = {};
                element.bind('click', function() {
                    param.moduleNo = attrs.moduleNo
                    param.formKey = RelativeModule[attrs.relativeModule]
                    var moduleName = Modulemap.getViewNameAndIcon(RelativeModule[attrs.relativeModule])
                    if (!moduleName || (param.moduleNo == "无"||param.moduleNo === "")) {
                        Util.Toast("移动端不支持该明细的查看或没有明细")
                        return
                    }
                    var url = "relativePage/" + moduleName.checkViewName + "/" + param.formKey + "/" + param.moduleNo;
                    // 返回时候判断是否是从关联模块进去的
                    Util.setRelMoNum(1)
                    $location.path(url)
                    scope.$apply()
                });
            }
        };
    }]);
